package com.laiyima.zhongjiang.linghuilv.demo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.laiyima.zhongjiang.linghuilv.demo.R;
import com.laiyima.zhongjiang.linghuilv.demo.bean.MymachineBean;

import java.util.List;

public class MymachineAdapter extends BaseAdapter {
    private Context mContext;
    private LayoutInflater mInflater;
    private List<MymachineBean> mMymachineBean;
    private String TAG = "AgentAdapter";

    public MymachineAdapter(Context context, List<MymachineBean> maxMymachineBeanDatas) {
        mContext = context;
        mInflater = LayoutInflater.from(context);
        mMymachineBean = maxMymachineBeanDatas;
    }

    @Override
    public int getCount() {
        return mMymachineBean.size();
    }

    @Override
    public Object getItem(int position) {
        return mMymachineBean.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.mymachine_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.mymachine_sn = convertView.findViewById(R.id.mymachine_sn);
            viewHolder.mymachine_desc = convertView.findViewById(R.id.mymachine_desc);
            viewHolder.mymachine_time = convertView.findViewById(R.id.mymachine_time);
            viewHolder.outof_binding = convertView.findViewById(R.id.outof_binding);
            viewHolder.mymachine_name = convertView.findViewById(R.id.mymachine_name);
            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        MymachineBean mymachineBean = mMymachineBean.get(position);
        viewHolder.mymachine_sn.setText(mymachineBean.getSn());
        viewHolder.mymachine_desc.setText(mymachineBean.getDesc());
        viewHolder.mymachine_time.setText(mymachineBean.getBindingTime());

        viewHolder.mymachine_name.setText(mymachineBean.getpId());


        return convertView;
    }


    public static class ViewHolder {
        TextView mymachine_sn;
        TextView mymachine_desc;
        TextView mymachine_time;
        TextView mymachine_name;
        Button outof_binding;
    }
}
